<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>DHTML Tree samples. dhtmlXTree - Editable items</title>
</head>
<style>
	body {font-size:12px}
	.{font-family:arial;font-size:12px}
	h1 {cursor:hand;font-size:16px;margin-left:10px;line-height:10px}
	xmp {color:green;font-size:12px;margin:0px;font-family:courier;background-color:#e6e6fa;padding:2px}
</style>
<body>
	<h1>Editable items</h1>
	<link rel="STYLESHEET" type="text/css" href="../css/dhtmlXTree.css">
	<script  src="../js/dhtmlXCommon.js"></script>
	<script  src="../js/dhtmlXTree.js"></script>
	<script  src="../js/dhtmlXTree_ed.js"></script>
	<script  src="../js/dhtmlXTree_kn.js"></script>
Double click any item to edit it.  <br/>
Title is validated and can't be empty.    
	<table>
		<tr>
			<td>
				<div id="treeboxbox_tree" style="width:250; height:218;background-color:#f5f5f5;border :1px solid Silver;; overflow:auto;"></div>
			</td>
			<td rowspan="2" style="padding-left:25" valign="top">
				<a href="#" onclick="tree.enableItemEditor(true);">Enable editing</a><br>
				<a href="#" onclick="tree.enableItemEditor(false);">Disable editing</a><br>
                <input type='checkbox' id='a1231' onclick="au()" checked='true'>Click on selected
                <input type='checkbox' id='a1232' onclick="au()" checked='true'>Double click
                <hr>
                <div id='a_1' style='height:200px; overflow:auto;'></div>
			</td>
		</tr>
		<tr>
			<td>
			</td>
		</tr>
	</table>
    <xmp>
            function m_func(state,id,tree,value){
                if ((state==2)&&(value=="")) return false;
                return true;
            }

			tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
			...
			//enable editing on doubleclick
			tree.enableItemEditor(true);
            //set validator function
            tree.setOnEditHandler(m_func);

			tree.loadXML("tree.xml");
    </xmp>
<hr>
	<script>
            function m_func(state,id,tree,value){
                document.getElementById("a_1").innerHTML+="<div>Item "+id+" - "+(state==0?"start editing":(state==1?"editor launched":(state==2?"editor closing":"editor closed")))+"</div>";

                if ((state==2)&&(value=="")) return false;
                return true;
            }

            function au(){
                tree.setEditStartAction(document.getElementById('a1231').checked,document.getElementById('a1232').checked);
            }
			tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
			tree.setImagePath("../imgs/");
			tree.enableSmartXMLParsing(true);
            tree.enableDragAndDrop(true);
			tree.setDragBehavior('complex');
			
            tree.enableItemEditor(true);
            /*tree.setOnEditHandler(function(st,id,treeObj,val){
				if(st==0 && treeObj.getLevel(id)<3)
					return false;
				else
					return true;
			})*/
			tree.setOnEditHandler(m_func);
			tree.loadXML("tree.xml");
	</script>
<br><br>

</body>
</html>
